
import numpy as np
from tensorflow.examples.tutorials.mnist import input_data

def decode_one_hot(label):
    return max([i for i in range(len(label)) if label[i] == 1])

def network_data():
    mnist = input_data.read_data_sets("MNIST_data", one_hot=True)
    train_inputs = [np.reshape(x, (784,1)) for x in mnist.train.images]
    train_results = [np.reshape(x, (10,1)) for x in mnist.train.labels]
    trainset = [(x,y) for x, y in zip(train_inputs, train_results)]

    test_inputs = [np.reshape(x, (784,1)) for x in mnist.test.images]
    test_results = [decode_one_hot(x) for x in mnist.test.labels]
    testset = [(x,y) for x, y in zip(test_inputs, test_results)]

    return trainset, testset

